package com.pactera.demo.social.qq.connet;

import com.pactera.demo.social.qq.api.IQQ;
import com.pactera.demo.social.qq.api.QQImpl;
import org.springframework.social.oauth2.AbstractOAuth2ServiceProvider;
import org.springframework.social.oauth2.OAuth2Operations;
import org.springframework.social.oauth2.OAuth2Template;

/**
 * <p>
 *
 * </p>
 *
 * @author chang.zhou
 * @version 1.0
 * @date Created in 2020/3/4 12:11
 */
public class QQServiceProvider extends AbstractOAuth2ServiceProvider<IQQ> {

    private String appId;

    private static final String URL_AUTHORIZE = "https://graph.qq.com/oauth2.0/authorize";
    private static final String URL_ACCESS_TOKEN = "https://graph.qq.com/oauth2.0/token";

    public QQServiceProvider(String appId,String appSecret) {
        super(new OAuth2Template(appId, appSecret, URL_AUTHORIZE, URL_ACCESS_TOKEN));
        this.appId = appId;
    }

    @Override
    public IQQ getApi(String accessToken) {
        return new QQImpl(accessToken, this.appId);
    }
}
